﻿#ifndef LOGINCONTROLLER_H
#define LOGINCONTROLLER_H
#include<QObject>
#include"StashManageControllerObject.h"
#include"LoginModel.h"
#include"LoginView.h"
#include"XQCreateAccountView.h"
//登录控制器
class LoginController:public StashManageControllerObject
{
	Q_OBJECT
public:
	LoginController(QObject* parent=nullptr);
	~LoginController();
public:
	LoginView* loginView()const;
public:
	void copyModel(StashManageModelObject* model)override;
	//读取登录配置文件
	void readLoginSettings();
	/*
	* @brief 显示视图.
	*/
	void showView();
signals://信号
	void loginSignals(const XQUserData& user);
protected slots://处理视图的操作请求
	/*
	* @brief 登录处理.
	* @param account:登录账号
	* @param password:登录密码
	*/
	void loginSlots(const QString& account, const QString& password);
	void loginViewUserNameChangedSlots(const QString& account);
	void createDatabaseConnectionViewSlots(XQDatabaseConnectionView* view);
	void databaseConnectionSlots(XQDatabaseConnectionModel data);
	void databaseSaveSlots(XQDatabaseConnectionModel data);
	void createAccountViewSlots(XQCreateUserView* view);
	void registerAccountSlots(const XQUserData& user);
	void sendVerifySlots();
protected://隐藏的函数
	//初始化
	void init();
	//数据库用户表初始化
	void initDatabaseTable();
private:
	QPointer<LoginView> m_LoginView;
	QPointer<XQDatabaseConnectionView> m_databaseConnectionView;
	QPointer<XQCreateUserView> m_createAccount ;
	qint64 m_verify=0;
	QDateTime m_updateVerify;
};
#endif // !LoginController_H
